package utils

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func WaitSignal(extfunc ...func()) {
	signalChan := make(chan os.Signal, 1)
	signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, os.Interrupt, os.Kill, syscall.SIGTERM)

	select {
	case v := <-signalChan:
		fmt.Println("WaitSignal ", v)
	}

	for _, v := range extfunc {
		if v != nil {
			v()
		}
	}

	time.Sleep(time.Millisecond * 10)
}
